from selenium import webdriver
import time

from selenium.webdriver.common.by import By


class Test_case:
    def __init__(self):
        self.driver = webdriver.Chrome()

    # 打开Chrome,打开so360首页

    def get_so(self):
        self.driver.get("https://www.so.com/")
        # 在搜索框输入"python自动化测试",点击搜索
        self.driver.find_element(By.ID,"input").send_keys("python自动化测试")
        self.driver.find_element(By.ID,"search-button").click()
        # 获取页面标题,并打印出来
        print(self.driver.title)
        # 检查python关键字是否在标题中
        if "python" in self.driver.title:
            print('抓到了')
        else:
            print('抓不到')

    # 关闭Chrome浏览器
    def quit(self):
        time.sleep(2)
        self.driver.quit()
    # 调用
case = Test_case()
case.get_so()

case.quit()







